#ifndef _ABUTTON_H_
# define _ABUTTON_H_

# include <string>
# include "Image.h"
# include "IScreen.h"

typedef bool (*ButtonCallBack)(IScreen*);

class AButton
{
public:
	struct ButtonState
	{
		static unsigned char const RELEASED; // Nothing
		static unsigned char const PRESSED; // Mouse button down
		static unsigned char const CLICKED; // Mouse button up
		static unsigned char const HOVERED; // Button not selected but mouse is hovering button
	};

protected:
	Image* m_currentSprite;
	char m_currentState;
	SDL_Rect m_position;
	ButtonCallBack m_callBack;
	IScreen* m_caller;
	Image m_text;
	std::string m_string;

public:
	AButton(IScreen* _caller, std::string const& _text = "");
	virtual ~AButton();

	virtual void updateState() = 0;
	bool draw(SDL_Surface* _screen);
	void initText();
	void setCurrentState(char _state);
	void setCallBack(ButtonCallBack);
	bool useCallBack();
	void setCaller(IScreen* _caller);
	virtual void setPosition(int _x, int _y);

	Image* getCurrentSprite();
	char getCurrentState() const;
	SDL_Rect& getPosition();
	ButtonCallBack getCallBack();
	IScreen* getCaller();

public:
	__declspec(property(get=getCurrentSprite))Image* CurrentSprite;
	__declspec(property(get=getCurrentState, put=setCurrentState))char CurrentState;
	__declspec(property(get=getPosition))SDL_Rect Position;
	__declspec(property(get=getCallBack, put=setCallBack))ButtonCallBack CallBack;
	__declspec(property(get=getCaller, put=setCaller))IScreen* Caller;

private:
	AButton(AButton const&);
	AButton& operator=(AButton const&);
};

#endif // _ABUTTON_H_
